import com.google.appengine.api.datastore.*
import static com.google.appengine.api.datastore.FetchOptions.Builder.*
 
// query the scripts stored in the datastore
def query = new Query("Concello")
 
query.addSort("numeroItems", Query.SortDirection.DESCENDING)
query.addFilter("numeroItems", Query.FilterOperator.GREATER_THAN, 0)
 
PreparedQuery preparedQuery = datastore.prepare(query)
 
// return only the first 20 results
def entities = preparedQuery.asList( withLimit(5) )

html.div(class:'lista-concellos', style:'width:600px; float:left;') {
	
	entities.eachWithIndex {concello,i->
		if (concello) {	
		
			div(class:"concello", style:'padding:20px 0;border-bottom:1px dashed #DDDDDD;') {
				div(class:'nome-concello', style:'text-align:center;width:120px;float:left;background:#9dc760') {
					p "${concello.nome}"
				}
				
				div(class:'desc-concello', style:'margin-left:130px;') {
					h3(style:'margin:0;padding:0 0 8px;') {
						a href:"concello/${concello.key.id}", "editar"
					}
					
					p "contido"
				}
			}
			
		}
	
	}
	
}

